/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2014_08_08			*/
/*	File:		GtRm2000.h			*/
/********************************************************/

#ifndef	_GTRM2000_H
#define	_GTRM2000_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "GtRmUtil.h"

#define	GT_R2_TIM			3
#define	GT_R2_LAN			4

#define	GT_R2_MIU			42	// mac + ip + udp
#define	GT_R2_MIT			54	// mac + ip + tcp

#define	GT_R2_MIN			GT_R2_MIU
#define	GT_R2_MAX			GT_KBYTES8

#define	GT_R2_LOG(format, args...)	do {			\
	sprintf(szTmp, format, ##args);				\
	sprintf(szLog + iLog, "%s", szTmp);			\
	iLog += strlen(szTmp);					\
	memset(szTmp, '\0', GT_BYTE128);			\
} while (0)

typedef struct tagGtR2Para
{
	int m_iSocket;
	UINT m_uiIndex;
        GTRUCONF_S* m_pstConf;
}GTR2PARA_S;

void GtR2Quit(int iSignal);
void* GtR2Routine(void* pPara);
int GtR2Main(UINT uiThread, GTR2PARA_S* pstPara);
int GtR2Fork(UINT uiThread, GTRUCONF_S* pstConf);
int GtR2Thread(UINT uiThread, GTR2PARA_S* pstPara);

inline int GtR2RawRecv(int iSocket, UCHAR* puszPacket, int iLength)
{
	return recvfrom(iSocket, puszPacket, iLength, 0, NULL, NULL);
}

inline int GtR2RawSend(int iSocket, UCHAR* puszPacket, int iLength, struct sockaddr* pstAddr, int iAddr)
{
	return sendto(iSocket, puszPacket, iLength, 0, pstAddr, iAddr);
}

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _GTRM2000_H */
